<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.dao.UserDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 系统管理&gt;&gt; 开放员工重新注册
</div>

<%
	{
	User registerUser = (User) session.getAttribute(Constants.SESSION_OPEN_REGISTER_USER);
	UserDao userDao = DaoCreator.createUserDao();
	session.removeAttribute(Constants.SESSION_OPEN_REGISTER_USER);
%>
<div class="tt">开放员工重新注册</div>
<div class="content">
	<table align="center" border="0" width="700" cellpadding="0"
		cellspacing="0" style="height:100px;">
		<tr>
			<td class="td1" height="35">
				<input type="hidden" name="userID" id="userID" value="<%=(registerUser == null)? "":registerUser.getId() %>"/>
				<input type="hidden" name="isRegistered" id="isRegistered" value="<%=(registerUser == null)? "":registerUser.isRegistered() %>"/>					
				<span style="margin-left: 30px" class="span1">姓 名：</span>
				<input type="text" name="name" id="name" size="15"  value="<%=(registerUser == null)? "":registerUser.getName() %>"/>
				<span style="margin-left: 20px" class="span1">工 号：</span>
				<input type="text" name="jobNum" id="jobNum" size="20"  value="<%=(registerUser == null)? "":registerUser.getJobNum() %>" />
				<span style="margin-left: 10px">输入工号后点击获取信息</span>
				<input type="button" style="margin-left: 4px" value="获取信息" onclick="refreshUserForOpenRegister()" />
			</td>
		</tr>
		<tr>
			<td class="td1" align="center">
				<input type="button" value="开放注册" onclick="updateUserOpenRegister()" />
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
function updateUserOpenRegister() {
	var userID = getElementValueByID('userID');
	var isRegistered = getElementValueByID('isRegistered');
	var name = getElementValueByID('name');
	var jobNum = getElementValueByID('jobNum');
	if(jobNum == '' || name == ''){
		$.dialog.alert('请先输入工号，然后获取信息');
		return;
	}
	
	if(isRegistered != 'true'){		
		$.dialog.alert('该用户还未注册，无需重新开放注册');
		return;
	}
	
$.dialog.confirm('您确认给'+name+'开放注册吗？', function(){
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'update_user_openregister_process.jsp',
		data:{			
			userID: userID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {					
					$.dialog(name+'已重新开放注册！', function() { loadPageSection('<%=request.getContextPath()%>/admin/open_register.jsp', 'mainContentDiv', {}, true); });					
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
});
}
</script>
<%
}
%>

